<template>
  <div>
    <el-table :data="attribute.tableData" border style="width: 100%">
      <el-table-column prop="id" label="ID" min-width="80"></el-table-column>
      <el-table-column prop="name" label="属性名称" min-width="80"></el-table-column>
      <el-table-column prop="attribute_category_id" label="属性分类" min-width="80">
        <template slot-scope="scope">{{
            shuxing(attribute.tableData[scope.$index].attribute_category_id) 
            }}</template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            @click="deletelist(scope.$index,attribute.tableData[scope.$index].id)"
            type="primary"
            size="small"
          >编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
//引入vuex
import { mapState } from "vuex";

export default {
  computed: {
    ...mapState(["attribute"])
  },
  //   方法
  methods: {
    deletelist(e, id) {
      console.log(e, id);
      this.$router.push({
        path: `/editattribute/${id}`,
        params: {
          id
        }
      });

      // this.$router.push("/editattribute");
    },
    shuxing(id) {
          // console.log(id)
          var name01=0
      this.attribute.category.map(val => {
        if (val.id === id) {
          name01 = val.name;
        }
      });
      return name01
    }
  }
};
</script>

<style>
</style>